<template>
  <div class='container'>
      <el-dialog title="试题预览" :visible.sync="isvisible" :before-close="close"   :close-on-click-modal="false"
        :close-on-press-escape="false">
  <el-row>
      <!-- 题型部分 -->
      <el-col :span="6">【题型】：{{questionItem.questionType|formatterQuestionType}}</el-col>
      <el-col :span="6">【编号】：{{questionItem.id}}</el-col>
      <el-col :span="6">
          <span>【难度】：{{questionItem.difficulty | formatterDifficulty}}</span>
      </el-col>
      <el-col :span="6">【标签】：{{questionItem.tags}}</el-col>
  </el-row>

<!-- 学科 -->
   <el-row>
      <el-col :span="6">【学科】：{{questionItem.subjectName}}</el-col>
      <el-col :span="6">【目录】：{{questionItem.directoryName}}</el-col>
      <el-col :span="6">【方向】：{{questionItem.direction}}</el-col>

  </el-row>

  <el-row>
      <hr/>
  </el-row>

<!-- 题干部分 -->
   <el-row>
      <el-col  :span="6"><span >【题干】：</span>
      <p style="color:blue" v-html="questionItem.question">{{questionItem.question}}</p>
      <p>单选题 选项：（以下选中的选项为正确答案）</p>

      <!-- 单选框 -->
      <div v-if="questionItem.questionType==='1'">
   <el-row style="margin-bottom:10px">

        <el-radio class="aaa" v-for="obj in questionItem.options" :key="obj.id" :label="obj.isRight" v-model="del" @change="del=1"
                  >{{obj.title}}</el-radio>
       </el-row>
      </div>

      <!-- 多选框 -->
      <div v-if="questionItem.questionType==='2'">
   <el-row style="margin-bottom:10px">

        <el-checkbox class="aaa" v-for="obj in questionItem.options" :key="obj.id" :label="1" :checked="obj.isRight===1"
                  >{{obj.title}}</el-checkbox>
       </el-row>
      </div>
      </el-col>
  </el-row>
<hr>
【参考答案】：<el-button type="danger" @click="isvideoFn">视频答案预览</el-button>
  <el-row >
      <!-- 视频控件 -->
<video
 :src="questionItem.videoURL"
  controls="controls"
  class="video"
  v-if="isvideo"
  autoplay
  ></video>
  </el-row>
  <hr>

  <!-- 答案解析 -->
  <el-row>
      【答案解析】：<span v-html="questionItem.remarks">{{questionItem.remarks}}</span>
  </el-row>
  <hr>
  <!-- 题目备注 -->
<el-row>
  【题目备注】：<span v-html="questionItem.remarks">{{questionItem.remarks}}</span>

</el-row>

<!-- 关闭按钮 -->
<el-row>
    <el-button class="btn" type="primary" @click="$emit('close')" >关 闭</el-button>
    </el-row>
      </el-dialog>
      </div>
</template>

<script>
import { difficulty, questionType } from '@/api/hmmm/constants'
export default {
  data () {
    return {
      del: 1,
      isvideo: false
    }
  },
  props: {
    isvisible: { type: Boolean, required: true },
    questionItem: { type: Object, require: true }
  },
  filters: {
    // 格式化题型
    formatterQuestionType (cellValue) {
    //   console.log(cellValue)
      const obj = questionType.find((item) => item.value === Number(cellValue))
      return obj ? obj.label : '未知'
    },
    // 格式化难度
    formatterDifficulty (cellValue) {
    //   console.log(cellValue)
      const obj = difficulty.find((item) => item.value === Number(cellValue))
      return obj ? obj.label : '未知'
    }
  },
  methods: {
    isvideoFn () {
      this.isvideo = true
    },
    close () {
      this.$emit('close')
    }

  }
}
</script>

<style scoped lang='scss'>
.el-row {
    margin-bottom: 20px;
}
.aaa {
    display: block;
    margin-bottom: 10px;
}
.video {
    width: 400px;
}
.btn{
  float: right;
}
</style>
